package org.dromara.learning_lhz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.dromara.learning_lhz.entity.AsStudentAdminEntity;
import org.dromara.learning_lhz.mapper.StudentAdminMapper;
import org.dromara.learning_lhz.service.StudentAdminService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
public class StudentAdminServiceImpl extends ServiceImpl<StudentAdminMapper, AsStudentAdminEntity> implements StudentAdminService {
    @Override
    public List<AsStudentAdminEntity> selStudentAdmin(AsStudentAdminEntity asStudentAdminEntity) {
        // 创建 LambdaQueryWrapper 进行查询条件的构建
        LambdaQueryWrapper<AsStudentAdminEntity> queryWrapper = new LambdaQueryWrapper<>();

        // 只根据姓名进行模糊查询
        if (Objects.nonNull(asStudentAdminEntity.getStudentName())) {
            queryWrapper.like(AsStudentAdminEntity::getStudentName, asStudentAdminEntity.getStudentName());
        }

        // 查询学生列表
        return this.list(queryWrapper);
    }
}
